import http from '@/utils/request'
const user = {
  state: {
    nickName: '',
    role: ''
  },
  mutations: {
    GET_USER_INFO(state, data) {
      state.nickName = data.nickName
      state.role = data.role
    }
  },
  actions: {
    getUserInfo({ commit }) {
      return new Promise(resolve => {
        http.post('/api/getUserInfo').then(res => {
          console.log(res)
          commit('GET_USER_INFO', res.data)
          resolve(res.data)
        })
      })
    }
  }
}

export default user
